package cc.prayol.permission.mapper.auth;

import static cc.prayol.permission.mapper.auth.OperationLogDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import cc.prayol.permission.entity.auth.OperationLog;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface OperationLogMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    BasicColumn[] selectList = BasicColumn.columnList(operId, title, businessType, method, operatorType, operName, deptName, operUrl, operIp, operLocation, operParam, status, errorMsg, operTime);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<OperationLog> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("OperationLogResult")
    Optional<OperationLog> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="OperationLogResult", value = {
        @Result(column="oper_id", property="operId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="business_type", property="businessType", jdbcType=JdbcType.INTEGER),
        @Result(column="method", property="method", jdbcType=JdbcType.VARCHAR),
        @Result(column="operator_type", property="operatorType", jdbcType=JdbcType.INTEGER),
        @Result(column="oper_name", property="operName", jdbcType=JdbcType.VARCHAR),
        @Result(column="dept_name", property="deptName", jdbcType=JdbcType.VARCHAR),
        @Result(column="oper_url", property="operUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="oper_ip", property="operIp", jdbcType=JdbcType.VARCHAR),
        @Result(column="oper_location", property="operLocation", jdbcType=JdbcType.VARCHAR),
        @Result(column="oper_param", property="operParam", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.SMALLINT),
        @Result(column="error_msg", property="errorMsg", jdbcType=JdbcType.VARCHAR),
        @Result(column="oper_time", property="operTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<OperationLog> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, operationLog, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, operationLog, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    default int deleteByPrimaryKey(Long operId_) {
        return delete(c -> 
            c.where(operId, isEqualTo(operId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    default int insert(OperationLog record) {
        return MyBatis3Utils.insert(this::insert, record, operationLog, c ->
            c.map(operId).toProperty("operId")
            .map(title).toProperty("title")
            .map(businessType).toProperty("businessType")
            .map(method).toProperty("method")
            .map(operatorType).toProperty("operatorType")
            .map(operName).toProperty("operName")
            .map(deptName).toProperty("deptName")
            .map(operUrl).toProperty("operUrl")
            .map(operIp).toProperty("operIp")
            .map(operLocation).toProperty("operLocation")
            .map(operParam).toProperty("operParam")
            .map(status).toProperty("status")
            .map(errorMsg).toProperty("errorMsg")
            .map(operTime).toProperty("operTime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    default int insertSelective(OperationLog record) {
        return MyBatis3Utils.insert(this::insert, record, operationLog, c ->
            c.map(operId).toPropertyWhenPresent("operId", record::getOperId)
            .map(title).toPropertyWhenPresent("title", record::getTitle)
            .map(businessType).toPropertyWhenPresent("businessType", record::getBusinessType)
            .map(method).toPropertyWhenPresent("method", record::getMethod)
            .map(operatorType).toPropertyWhenPresent("operatorType", record::getOperatorType)
            .map(operName).toPropertyWhenPresent("operName", record::getOperName)
            .map(deptName).toPropertyWhenPresent("deptName", record::getDeptName)
            .map(operUrl).toPropertyWhenPresent("operUrl", record::getOperUrl)
            .map(operIp).toPropertyWhenPresent("operIp", record::getOperIp)
            .map(operLocation).toPropertyWhenPresent("operLocation", record::getOperLocation)
            .map(operParam).toPropertyWhenPresent("operParam", record::getOperParam)
            .map(status).toPropertyWhenPresent("status", record::getStatus)
            .map(errorMsg).toPropertyWhenPresent("errorMsg", record::getErrorMsg)
            .map(operTime).toPropertyWhenPresent("operTime", record::getOperTime)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    default Optional<OperationLog> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, operationLog, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    default List<OperationLog> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, operationLog, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    default List<OperationLog> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, operationLog, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    default Optional<OperationLog> selectByPrimaryKey(Long operId_) {
        return selectOne(c ->
            c.where(operId, isEqualTo(operId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, operationLog, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    static UpdateDSL<UpdateModel> updateAllColumns(OperationLog record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(operId).equalTo(record::getOperId)
                .set(title).equalTo(record::getTitle)
                .set(businessType).equalTo(record::getBusinessType)
                .set(method).equalTo(record::getMethod)
                .set(operatorType).equalTo(record::getOperatorType)
                .set(operName).equalTo(record::getOperName)
                .set(deptName).equalTo(record::getDeptName)
                .set(operUrl).equalTo(record::getOperUrl)
                .set(operIp).equalTo(record::getOperIp)
                .set(operLocation).equalTo(record::getOperLocation)
                .set(operParam).equalTo(record::getOperParam)
                .set(status).equalTo(record::getStatus)
                .set(errorMsg).equalTo(record::getErrorMsg)
                .set(operTime).equalTo(record::getOperTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.612+08:00", comments="Source Table: sys_oper_log")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(OperationLog record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(operId).equalToWhenPresent(record::getOperId)
                .set(title).equalToWhenPresent(record::getTitle)
                .set(businessType).equalToWhenPresent(record::getBusinessType)
                .set(method).equalToWhenPresent(record::getMethod)
                .set(operatorType).equalToWhenPresent(record::getOperatorType)
                .set(operName).equalToWhenPresent(record::getOperName)
                .set(deptName).equalToWhenPresent(record::getDeptName)
                .set(operUrl).equalToWhenPresent(record::getOperUrl)
                .set(operIp).equalToWhenPresent(record::getOperIp)
                .set(operLocation).equalToWhenPresent(record::getOperLocation)
                .set(operParam).equalToWhenPresent(record::getOperParam)
                .set(status).equalToWhenPresent(record::getStatus)
                .set(errorMsg).equalToWhenPresent(record::getErrorMsg)
                .set(operTime).equalToWhenPresent(record::getOperTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.613+08:00", comments="Source Table: sys_oper_log")
    default int updateByPrimaryKey(OperationLog record) {
        return update(c ->
            c.set(title).equalTo(record::getTitle)
            .set(businessType).equalTo(record::getBusinessType)
            .set(method).equalTo(record::getMethod)
            .set(operatorType).equalTo(record::getOperatorType)
            .set(operName).equalTo(record::getOperName)
            .set(deptName).equalTo(record::getDeptName)
            .set(operUrl).equalTo(record::getOperUrl)
            .set(operIp).equalTo(record::getOperIp)
            .set(operLocation).equalTo(record::getOperLocation)
            .set(operParam).equalTo(record::getOperParam)
            .set(status).equalTo(record::getStatus)
            .set(errorMsg).equalTo(record::getErrorMsg)
            .set(operTime).equalTo(record::getOperTime)
            .where(operId, isEqualTo(record::getOperId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.613+08:00", comments="Source Table: sys_oper_log")
    default int updateByPrimaryKeySelective(OperationLog record) {
        return update(c ->
            c.set(title).equalToWhenPresent(record::getTitle)
            .set(businessType).equalToWhenPresent(record::getBusinessType)
            .set(method).equalToWhenPresent(record::getMethod)
            .set(operatorType).equalToWhenPresent(record::getOperatorType)
            .set(operName).equalToWhenPresent(record::getOperName)
            .set(deptName).equalToWhenPresent(record::getDeptName)
            .set(operUrl).equalToWhenPresent(record::getOperUrl)
            .set(operIp).equalToWhenPresent(record::getOperIp)
            .set(operLocation).equalToWhenPresent(record::getOperLocation)
            .set(operParam).equalToWhenPresent(record::getOperParam)
            .set(status).equalToWhenPresent(record::getStatus)
            .set(errorMsg).equalToWhenPresent(record::getErrorMsg)
            .set(operTime).equalToWhenPresent(record::getOperTime)
            .where(operId, isEqualTo(record::getOperId))
        );
    }
}